import React, {Component} from 'react'
import {Link} from 'react-router'
import '../sass/Station'

export default class Station extends Component {
  constructor() {
    super()
  }

  render() {
    let {canPayByCredit, whetherIsCustomizedSite, type, fetchSwitchCartItem, isSupportDelivery, showSelect, confirmOrderAddressVos} = this.props

    return (
        <div className="cart-address-select">
            { confirmOrderAddressVos.length ?
                confirmOrderAddressVos.map((item, index) =>
                  item.selected && <div key={index} className="address" onClick={isSupportDelivery ? showSelect.bind(this) : null}>
                        {/*<div className="sign">*/}
                            {/*{item.type == 1 ? <span className="pick">自提</span> : <span className="delivery">配送</span>}*/}
                        {/*</div>*/}
                        <div className={isSupportDelivery ? 'detail active' : 'detail'}>
                            <p>{item.type == 1 ? item.siteName : item.address}</p>
                            <span>{item.type == 1 ? item.address : `${item.userName} ${item.telephone}`}</span>
                        </div>
                    </div>
                ) :
                <Link className="address-none" to="/editaddress/0">
                    添加收货地址<i className="iconfont icon-jiahao"/>
                </Link>
            }
            {canPayByCredit && whetherIsCustomizedSite && <div className="cart-station">
                <div className="station">
                  {/* <img src={require('../images/location.png')} alt="location"/>*/}
                  {/* <span>{siteAddress}</span>*/}
                  购物车类型
                </div>
                {/* <Link className="link" to="/stations/cart">切换</Link>*/}
                <div className="type-wrapper">
                    <div className="type">
                        {type === 1 ?
                        <div className="fl active">
                            个人
                        </div> :
                        <div className="fl" onClick={fetchSwitchCartItem.bind(this, {type: 1})}>
                            个人
                        </div>
                        }
                        {type === 2 ?
                        <div className="fr active">
                            企业
                        </div> :
                        <div className="fr" onClick={fetchSwitchCartItem.bind(this, {type: 2})}>
                            企业
                        </div>
                        }
                    </div>
                </div>
            </div>}
        </div>
    )
  }
}
